﻿Public Class ByteBuffer
    Private m_Buffer() As Byte = {}
    Private m_Count As Integer
    Public Sub Add(ByVal Bytes As Byte())
        Dim TA(m_Buffer.Length + Bytes.Length - 1) As Byte
        Array.Copy(m_Buffer, TA, m_Buffer.Length)
        Array.Copy(Bytes, 0, TA, m_Buffer.Length, Bytes.Length)
        m_Buffer = TA
        m_Count = m_Buffer.Length
    End Sub
    Public Function GetBytes(ByVal Count As Integer) As Byte()
        Dim T(Count - 1) As Byte
        Array.Copy(m_Buffer, T, Count)
        Dim TR(m_Buffer.Length - Count - 1) As Byte
        Array.Copy(m_Buffer, Count, TR, 0, TR.Length)
        m_Buffer = TR
        m_Count = m_Buffer.Length
        Return T
    End Function
    Public ReadOnly Property Length() As Integer
        Get
            Return m_Count
        End Get
    End Property
    Public Function ToArray() As Byte()
        Return m_Buffer
    End Function

    Public Sub New()

    End Sub
End Class
